/**
 * 
 */
package com.kunbo.cn.service.impl.core.reporting;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletResponse;

import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.hssf.usermodel.HSSFPrintSetup;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.ss.util.CellRangeAddress;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import com.kunbo.cn.entity.core.poundlist.PurchasePoundList;
import com.kunbo.cn.entity.core.reporting.PurchaseReporting;
import com.kunbo.cn.service.core.reporting.PurchaseReportingService;
import com.kunbo.cn.util.common.Array;
import com.kunbo.cn.util.date.CommonsUtil;
import com.kunbo.cn.util.retu.Pages;

/**
 *
 * @author bjl  
 * @date 2019年4月8日 
 */
@Service
public class PurchaseReportingServiceImpl implements PurchaseReportingService {
	private static final Font BOLDWEIGHT_NORMAL = null;
	@Autowired
	private JdbcTemplate jdbc;
	public List<Map<String, Object>> getPurchPoundList(String supplier,String receivingUnit,String materiel,
			String wagonNumber,String transport_unit,String driver,String matter_type,String start_time,String end_time,Integer page,Integer pageSize) {
		/*String sql="SELECT * from business_customer_users_manage where 1=1";
		sql +=" and login_name =  '" + login_name + "'";
		System.out.println("（*************login_name列表**************）"+login_name);
		List<Map<String, Object>> one = jdbc.queryForList(sql);
		String t = String.valueOf(one.get(0).get("customer").toString());//customerid
	System.out.println("（*************t列表**************）"+t);*/
			String sql1 = "SELECT \r\n" + 
					"	p.* \r\n" + 
					"FROM \r\n" + 
					"	db_business_purchase_pound_list p \r\n" + 
					"WHERE   1 = 1 ";
			if(supplier != null && !supplier.isEmpty()){
				sql1 += " and p.supplier = '" + supplier + "'";
			}
			if(receivingUnit != null && !receivingUnit.isEmpty()){
				sql1 += " and p.receiving_unit =  '" + receivingUnit + "'";
			}
			if(materiel != null && !materiel.isEmpty()){
				sql1 += " and p.materiel = '" + materiel + "'";
			}
			if(wagonNumber != null && !wagonNumber.isEmpty()){
				sql1 += " and p.wagon_number =  '" + wagonNumber + "'";
			}
			if(transport_unit != null && !transport_unit.isEmpty()){
				sql1 += " and p.transport_unit = '" + transport_unit + "'";
			}
			if(driver != null && !driver.isEmpty()){
				sql1 += " and p.driver = '" + driver + "'";
			}
			if(matter_type != null && !matter_type.isEmpty()){
				sql1 += " and p.matter_type = '" + matter_type + "'";
			}
			/*if(materiel != null && !materiel.isEmpty()){
				sql1 += " and p.sale_order_code like '%" + sale_order_code + "%'";
			}*/
			if(start_time != null && !start_time.isEmpty()){
				sql1 += " and p.create_time >= '" + start_time + "'";
			}
			if(end_time != null && !end_time.isEmpty()) {
				 Long cTime= CommonsUtil.stringToTime(end_time)+86400000L;//时间加1天
				 String end=CommonsUtil.timeToString(cTime);
				sql1 += " and p.create_time < '" + end + "'";
			}
			System.out.println("（*************sql1列表**************）"+sql1);
			//sql1 += " and p.state <> 5 and p.state <> 6 " ;
			sql1 += " order by p.create_time  desc  limit " + (page * pageSize) +"," + pageSize;
			System.out.println(sql1+"<!!!!!!!!!!!!!!!!!!!!");
			List<Map<String, Object>> list = jdbc.queryForList(sql1);
			Integer count=list.size();
			//Map<String,Object> m = new HashMap<String, Object>();  
		   // m.put("count", count);  
			//System.out.println(count+"[!!!!!!!!!count!!!!!!!!!]");
			//list.
			/*for (Map<String, Object> map : list) {
				
				
				List<String>li=new ArrayList<String>();
				Double  num=null;
				
				//String material_sql = "select create_time,last_modified_time from db_business_purchase_pound_list  '" +Integer.parseInt( map.get("state").toString()) +"'";
				String material_sql = "select create_time,last_modified_time from db_business_purchase_pound_list " ;
				
				//String end=CommonsUtil.timeToString(cTime);
				if(jdbc.queryForList(material_sql) != null && jdbc.queryForList(material_sql).size() > 0) {
					//map.put("create_time",CommonsUtil.timeToString(Long.parseLong(jdbc.queryForList(material_sql).get(0).get("create_time"))) );
					map.put("create_time",jdbc.queryForList(material_sql).get(0).get("create_time"));
					System.out.println("@@@@@@@time@@@@@@@@"+jdbc.queryForList(material_sql).get(0).get("create_time").toString());
				//Object time=jdbc.queryForList(material_sql).get(0).get("create_time").toString();
				//Long time1=Long.parseLong((String) time);
				//CommonsUtil.timeToString(time1);
				//.out.println(time1+"[*********time1********]");
				//CommonsUtil.timeToString(time);
				}
				
				Double t=(Double) map.get("tare");
				//num=Integer.parseInt(t);
				num=num+t;
				System.out.println("{!!!!!!!!!!!!num!!!!!!!!!!!!}"+num);
				
			}*/
			
			//list.add();
			
			//list.add(m);
			/*String sqlCount = sql1;
			  sql1 += " limit " + page + "," + pageSize;
			  System.out.println(sql1);
			  List<Map<String, Object>> list =   jdbc.queryForList(sql);
			  Map<String,Object> map = new HashMap<String,Object>();
			  map.put("count", jdbc.queryForList(sqlCount).size());
			  list.add(map);*/
			return list;
	}//
	public Pages getPurchPoundList1(String supplier,String receivingUnit,String materiel,
			String wagonNumber,String transport_unit,String driver,String matter_type,String start_time,String end_time,Integer page,Integer pageSize) {
		/*String sql="SELECT * from business_customer_users_manage where 1=1";
		sql +=" and login_name =  '" + login_name + "'";
		System.out.println("（*************login_name列表**************）"+login_name);
		List<Map<String, Object>> one = jdbc.queryForList(sql);
		String t = String.valueOf(one.get(0).get("customer").toString());//customerid
	System.out.println("（*************t列表**************）"+t);*/
			String sql1 = "SELECT \r\n" + 
					"	p.* \r\n" + 
					"FROM \r\n" + 
					"	db_business_purchase_pound_list p \r\n" + 
					"WHERE   1 = 1 ";
			if(supplier != null && !supplier.isEmpty()){
				sql1 += " and p.supplier = '" + supplier + "'";
			}
			if(receivingUnit != null && !receivingUnit.isEmpty()){
				sql1 += " and p.receiving_unit =  '" + receivingUnit + "'";
			}
			if(materiel != null && !materiel.isEmpty()){
				sql1 += " and p.materiel = '" + materiel + "'";
			}
			if(wagonNumber != null && !wagonNumber.isEmpty()){
				sql1 += " and p.wagon_number =  '" + wagonNumber + "'";
			}
			if(transport_unit != null && !transport_unit.isEmpty()){
				sql1 += " and p.transport_unit = '" + transport_unit + "'";
			}
			if(driver != null && !driver.isEmpty()){
				sql1 += " and p.driver = '" + driver + "'";
			}
			if(matter_type != null && !matter_type.isEmpty()){
				sql1 += " and p.matter_type = '" + matter_type + "'";
			}
			/*if(materiel != null && !materiel.isEmpty()){
				sql1 += " and p.sale_order_code like '%" + sale_order_code + "%'";
			}*/
			if(start_time != null && !start_time.isEmpty()){
				sql1 += " and p.create_time >= '" + start_time + "'";
			}
			if(end_time != null && !end_time.isEmpty()) {
				 Long cTime= CommonsUtil.stringToTime(end_time)+86400000L;//时间加1天
				 String end=CommonsUtil.timeToString(cTime);
				sql1 += " and p.create_time < '" + end + "'";
			}
			System.out.println("（*************sql1列表**************）"+sql1);
			//sql1 += " and p.state <> 5 and p.state <> 6 " ;
			String sql2="";
			sql2 += " order by p.create_time  desc  limit " + (page * pageSize) +"," + pageSize;
			System.out.println(sql1+"<!!!!!!!!!!!!!!!!!!!!");
			String sql=sql1.concat(sql2);
			List<Map<String, Object>> list = jdbc.queryForList(sql);
			Pages pages =new Pages();
			  Integer count = jdbc.queryForList(sql1).size();
			  pages.setTotal(count);
			  pages.setData(list);
			
			return pages;
	}//
	public List<Map<String, Object>> getPurchMatterCount(String supplier,String receivingUnit,String materiel,
			String wagonNumber,String transport_unit,String driver,String matter_type,String start_time,String end_time,Integer page,Integer pageSize) {
		
			String sql1 = "SELECT \r\n" + //oldNetWeight //原发净重  roughWeight;//毛重  tare;//皮重  netWeight;//净重   loss;//亏损  
					"	p.supplier,p.materiel,count(materiel) as vehicle_number,sum(old_net_weight) as t_old_net_weight,sum(rough_weight) "
					+ "as t_rough_weight,sum(tare)as t_tare,sum(net_weight) as t_net_weight ,sum(loss) as t_loss \r\n" + 
					"FROM \r\n" + 
					"	db_business_purchase_pound_list p \r\n" + 
					"WHERE   1 = 1 ";
			if(supplier != null && !supplier.isEmpty()){
				sql1 += " and p.supplier = '" + supplier + "'";
			}
			if(receivingUnit != null && !receivingUnit.isEmpty()){
				sql1 += " and p.receiving_unit =  '" + receivingUnit + "'";
			}
			if(materiel != null && !materiel.isEmpty()){
				sql1 += " and p.materiel = '" + materiel + "'";
			}
			if(wagonNumber != null && !wagonNumber.isEmpty()){
				sql1 += " and p.wagon_number =  '" + wagonNumber + "'";
			}
			if(transport_unit != null && !transport_unit.isEmpty()){
				sql1 += " and p.transport_unit = '" + transport_unit + "'";
			}
			if(driver != null && !driver.isEmpty()){
				sql1 += " and p.driver = '" + driver + "'";
			}
			if(matter_type != null && !matter_type.isEmpty()){
				sql1 += " and p.matter_type = '" + matter_type + "'";
			}
			/*if(materiel != null && !materiel.isEmpty()){
				sql1 += " and p.sale_order_code like '%" + sale_order_code + "%'";
			}*/
			if(start_time != null && !start_time.isEmpty()){
				sql1 += " and p.create_time >= '" + start_time + "'";
			}
			if(end_time != null && !end_time.isEmpty()) {
				 Long cTime= CommonsUtil.stringToTime(end_time)+86400000L;//时间加1天
				 String end=CommonsUtil.timeToString(cTime);
				sql1 += " and p.create_time < '" + end + "'";
			}
			sql1 +=" GROUP BY p.materiel \r\n";
			System.out.println("（*************sql1列表**************）"+sql1);
			//sql1 += " and p.state <> 5 and p.state <> 6 " ;
			sql1 += " order by p.create_time  desc  limit " + (page * pageSize) +"," + pageSize;
			System.out.println(sql1+"<!!!!!!!!!!!!!!!!!!!!");
			List<Map<String, Object>> list = jdbc.queryForList(sql1);
			return list;
	}//
	public Pages getPurchMatterCount1(String supplier,String receivingUnit,String materiel,
			String wagonNumber,String transport_unit,String driver,String matter_type,String start_time,String end_time,Integer page,Integer pageSize) {
		
			String sql1 = "SELECT \r\n" + //oldNetWeight //原发净重  roughWeight;//毛重  tare;//皮重  netWeight;//净重   loss;//亏损  
					"	p.supplier,p.materiel,count(materiel) as vehicle_number,sum(old_net_weight) as t_old_net_weight,sum(rough_weight) "
					+ "as t_rough_weight,sum(tare)as t_tare,sum(net_weight) as t_net_weight ,sum(loss) as t_loss \r\n" + 
					"FROM \r\n" + 
					"	db_business_purchase_pound_list p \r\n" + 
					"WHERE   1 = 1 ";
			if(supplier != null && !supplier.isEmpty()){
				sql1 += " and p.supplier = '" + supplier + "'";
			}
			if(receivingUnit != null && !receivingUnit.isEmpty()){
				sql1 += " and p.receiving_unit =  '" + receivingUnit + "'";
			}
			if(materiel != null && !materiel.isEmpty()){
				sql1 += " and p.materiel = '" + materiel + "'";
			}
			if(wagonNumber != null && !wagonNumber.isEmpty()){
				sql1 += " and p.wagon_number =  '" + wagonNumber + "'";
			}
			if(transport_unit != null && !transport_unit.isEmpty()){
				sql1 += " and p.transport_unit = '" + transport_unit + "'";
			}
			if(driver != null && !driver.isEmpty()){
				sql1 += " and p.driver = '" + driver + "'";
			}
			if(matter_type != null && !matter_type.isEmpty()){
				sql1 += " and p.matter_type = '" + matter_type + "'";
			}
			/*if(materiel != null && !materiel.isEmpty()){
				sql1 += " and p.sale_order_code like '%" + sale_order_code + "%'";
			}*/
			if(start_time != null && !start_time.isEmpty()){
				sql1 += " and p.create_time >= '" + start_time + "'";
			}
			if(end_time != null && !end_time.isEmpty()) {
				 Long cTime= CommonsUtil.stringToTime(end_time)+86400000L;//时间加1天
				 String end=CommonsUtil.timeToString(cTime);
				sql1 += " and p.create_time < '" + end + "'";
			}
			sql1 +=" GROUP BY p.materiel \r\n";
			System.out.println("（*************sql1列表**************）"+sql1);
			//sql1 += " and p.state <> 5 and p.state <> 6 " ;
			String sql2="";
			sql2+= " order by p.create_time  desc  limit " + (page * pageSize) +"," + pageSize;
			System.out.println(sql1+"<!!!!!!!!!!!!!!!!!!!!");
			String sql=sql1.concat(sql2);//获取数据sql
			List<Map<String, Object>> list = jdbc.queryForList(sql);
			Pages pages =new Pages();
			  Integer count = jdbc.queryForList(sql1).size();
			  pages.setTotal(count);
			  pages.setData(list);
			return pages;
	}//
	public List<Map<String, Object>> getPurchUnitCount(String supplier,String receivingUnit,String materiel,
			String wagonNumber,String transport_unit,String driver,String matter_type,String start_time,String end_time,Integer page,Integer pageSize) {
			String sql1 = "SELECT \r\n" + 
					"	p.supplier,p.materiel,count(supplier) as vehicle_number,sum(old_net_weight) as t_old_net_weight,sum(rough_weight) "
					+ "as t_rough_weight,sum(tare)as t_tare,sum(net_weight) as t_net_weight ,sum(loss) as t_loss \r\n" + 
					"FROM \r\n" + 
					"	db_business_purchase_pound_list p \r\n" + 
					"WHERE   1 = 1 ";
			if(supplier != null && !supplier.isEmpty()){
				sql1 += " and p.supplier = '" + supplier + "'";
			}
			if(receivingUnit != null && !receivingUnit.isEmpty()){
				sql1 += " and p.receiving_unit =  '" + receivingUnit + "'";
			}
			if(materiel != null && !materiel.isEmpty()){
				sql1 += " and p.materiel = '" + materiel + "'";
			}
			if(wagonNumber != null && !wagonNumber.isEmpty()){
				sql1 += " and p.wagon_number =  '" + wagonNumber + "'";
			}
			if(transport_unit != null && !transport_unit.isEmpty()){
				sql1 += " and p.transport_unit = '" + transport_unit + "'";
			}
			if(driver != null && !driver.isEmpty()){
				sql1 += " and p.driver = '" + driver + "'";
			}
			if(matter_type != null && !matter_type.isEmpty()){
				sql1 += " and p.matter_type = '" + matter_type + "'";
			}
			/*if(materiel != null && !materiel.isEmpty()){
				sql1 += " and p.sale_order_code like '%" + sale_order_code + "%'";
			}*/
			if(start_time != null && !start_time.isEmpty()){
				sql1 += " and p.create_time >= '" + start_time + "'";
			}
			if(end_time != null && !end_time.isEmpty()) {
				 Long cTime= CommonsUtil.stringToTime(end_time)+86400000L;//时间加1天
				 String end=CommonsUtil.timeToString(cTime);
				sql1 += " and p.create_time < '" + end + "'";
			}
			sql1 +=" GROUP BY p.supplier \r\n";
			System.out.println("（*************sql1列表**************）"+sql1);
			//sql1 += " and p.state <> 5 and p.state <> 6 " ;
			sql1 += " order by p.create_time  desc  limit " + (page * pageSize) +"," + pageSize;
			System.out.println(sql1+"<!!!!!!!!!!!!!!!!!!!!");
			List<Map<String, Object>> list = jdbc.queryForList(sql1);
			return list;
	}
	public Pages getPurchUnitCount1(String supplier,String receivingUnit,String materiel,
			String wagonNumber,String transport_unit,String driver,String matter_type,String start_time,String end_time,Integer page,Integer pageSize) {
			String sql1 = "SELECT \r\n" + 
					"	p.supplier,p.materiel,count(supplier) as vehicle_number,sum(old_net_weight) as t_old_net_weight,sum(rough_weight) "
					+ "as t_rough_weight,sum(tare)as t_tare,sum(net_weight) as t_net_weight ,sum(loss) as t_loss \r\n" + 
					"FROM \r\n" + 
					"	db_business_purchase_pound_list p \r\n" + 
					"WHERE   1 = 1 ";
			if(supplier != null && !supplier.isEmpty()){
				sql1 += " and p.supplier = '" + supplier + "'";
			}
			if(receivingUnit != null && !receivingUnit.isEmpty()){
				sql1 += " and p.receiving_unit =  '" + receivingUnit + "'";
			}
			if(materiel != null && !materiel.isEmpty()){
				sql1 += " and p.materiel = '" + materiel + "'";
			}
			if(wagonNumber != null && !wagonNumber.isEmpty()){
				sql1 += " and p.wagon_number =  '" + wagonNumber + "'";
			}
			if(transport_unit != null && !transport_unit.isEmpty()){
				sql1 += " and p.transport_unit = '" + transport_unit + "'";
			}
			if(driver != null && !driver.isEmpty()){
				sql1 += " and p.driver = '" + driver + "'";
			}
			if(matter_type != null && !matter_type.isEmpty()){
				sql1 += " and p.matter_type = '" + matter_type + "'";
			}
			/*if(materiel != null && !materiel.isEmpty()){
				sql1 += " and p.sale_order_code like '%" + sale_order_code + "%'";
			}*/
			if(start_time != null && !start_time.isEmpty()){
				sql1 += " and p.create_time >= '" + start_time + "'";
			}
			if(end_time != null && !end_time.isEmpty()) {
				 Long cTime= CommonsUtil.stringToTime(end_time)+86400000L;//时间加1天
				 String end=CommonsUtil.timeToString(cTime);
				sql1 += " and p.create_time < '" + end + "'";
			}
			sql1 +=" GROUP BY p.supplier \r\n";
			System.out.println("（*************sql1列表**************）"+sql1);
			//sql1 += " and p.state <> 5 and p.state <> 6 " ;
			String sql2="";
			sql2+= " order by p.create_time  desc  limit " + (page * pageSize) +"," + pageSize;
			System.out.println(sql1+"<!!!!!!!!!!!!!!!!!!!!");
			  String sql=sql1.concat(sql2);//获取数据sql
			List<Map<String, Object>> list = jdbc.queryForList(sql);
			Pages pages =new Pages();
			  Integer count = jdbc.queryForList(sql1).size();
			  pages.setTotal(count);
			  pages.setData(list);
			return pages;
	}
	
	public Object[][] getPurchPoundExport(String supplier,String receivingUnit,String materiel,
			String wagonNumber,String transport_unit,String driver,String matter_type,String start_time,String end_time) {
		
			String sql1 = "SELECT \r\n" + 
					"	p.arrival_of_goods_number,p.supplier,p.materiel,p.wagon_number,p.transport_unit,p.old_net_weight,p.rough_weight,p.tare,p.net_weight,p.loss ,p.light_car_time,p.reconditioning_time \r\n" + 
					"FROM \r\n" + 
					"	db_business_purchase_pound_list p \r\n"+ 
		            "WHERE   1 = 1 ";
			//合计
			String sql5 = "SELECT \r\n" + 
					"	p.arrival_of_goods_number,p.supplier,p.materiel,p.wagon_number,p.transport_unit,sum(p.old_net_weight) as t_old_net_weight,sum(p.rough_weight) as t_rough_weight,sum(p.tare) as t_tare,(p.net_weight) as t_net_weight,(p.loss) as t_loss ,p.light_car_time,p.reconditioning_time \r\n" + 
					"FROM \r\n" + 
					"	db_business_purchase_pound_list p \r\n"+ 
		            "WHERE   1 = 1 ";

         String sql2="";
			if(supplier != null && !supplier.isEmpty()){
				sql2 += " and p.supplier = '" + supplier + "'";
			}
			if(receivingUnit != null && !receivingUnit.isEmpty()){
				sql2 += " and p.receiving_unit =  '" + receivingUnit + "'";
			}
			if(materiel != null && !materiel.isEmpty()){
				sql2 += " and p.materiel = '" + materiel + "'";
			}
			if(wagonNumber != null && !wagonNumber.isEmpty()){
				sql2 += " and p.wagon_number =  '" + wagonNumber + "'";
			}
			if(transport_unit != null && !transport_unit.isEmpty()){
				sql2 += " and p.transport_unit = '" + transport_unit + "'";
			}
			if(driver != null && !driver.isEmpty()){
				sql2 += " and p.driver = '" + driver + "'";
			}
			if(matter_type != null && !matter_type.isEmpty()){
				sql2 += " and p.matter_type = '" + matter_type + "'";
			}
			if(start_time != null && !start_time.isEmpty()){
				sql2 += " and p.create_time >= '" + start_time + "'";
			}
			if(end_time != null && !end_time.isEmpty()) {
				 Long cTime= CommonsUtil.stringToTime(end_time)+86400000L;//时间加1天
				 String end=CommonsUtil.timeToString(cTime);
				sql2 += " and p.create_time < '" + end + "'";
			}
			System.out.println("（*************sql1列表**************）"+sql1);
			  String sql3= " order by p.create_time  desc  ";
			  String sqla=sql2.concat(sql3);
			  String sql=sql1.concat(sqla);//获取数据sql
			  String sqlb= sql5.concat(sqla);//合计
			  System.out.println("[(((((((((数据sql))))))))]"+sql);
			  System.out.println("[(((((((((合计sql))))))))]"+sqlb);
			List<Map<String, Object>> list= jdbc.queryForList(sql);//sql1
			List<Map<String, Object>> countlist= jdbc.queryForList(sqlb);
			Map<String,Object> sa=countlist.get(0);//获取合计数据
			String t_old_net_weight=String.valueOf(sa.get("t_old_net_weight"));
			String t_rough_weight=String.valueOf(sa.get("t_rough_weight"));
			String t_tare=String.valueOf(sa.get("t_tare"));
			String t_net_weight=String.valueOf(sa.get("t_net_weight"));
			String t_loss=String.valueOf(sa.get("t_loss"));
			
			String []one= {"合计"," "," "," "," ",t_old_net_weight,t_rough_weight,t_tare,t_net_weight,t_loss," "," "};
			System.out.println("((((((((((((输出one[])))))))))"+Arrays.toString(one));
		        int size = list.size();
		        Object[][] array = new Object[size][12];
		       // Object[][] count = new Object[1][12];
		        //表头 
		       String[] arr={"到货通知单号","供应商","物料","车号","运输单位","原发净重","毛重","皮重","净重","亏损","轻车时间","重车时间"};
		        //表头 一维数组转进二维
		        int n = 12;//列
		        int m = arr.length/ n ;//行
		        Object [][] b = new Object[m][n];
		        int num = -1;
		        for (int i = 0; i < m; i++) {
		        for (int j = 0; j < n; j++) {
		        num++;
		        b[i][j] = arr[num];
		        }
		        }
		        System.out.println("((((((((((((输出arr[])))))))))"+Arrays.toString(arr));
		        System.out.println("((((((((((((输出b[][])))))))))"+Arrays.toString(b));
		        // System.out.println("[:::二维数组one::]"+Arrays.toString(one));
		        int x = 12;//列
		        int y = one.length/ x;//行
		        Object [][] c = new Object[y][x];
		        num = -1;
		        for (int i = 0; i < y; i++) {
		        for (int j = 0; j < x; j++) {
		        num++;
		        c[i][j] = one[num];
		        }
		        }
		        System.out.println("((((((((((((输出c[])))))))))"+Arrays.toString(c));
		        for (int i =0; i < size; i++) {//循环遍历所有行
		            array[i] = list.get(i).values().toArray();//每行的列数
		        }
		       //合并数组
		        Object[][] strs3 = Array.unite(b, array);
		        /*for(Object[] list1 : strs3) {//二维数组转一维
		        for(Object s : list1) {
		        System.out.print(s + "  合并数组 ：");
		        }
		        }*/
		     //合并统计数组
		        Object[][] total = Array.unite(strs3, c);
		        for(Object[] listC : c) {
		        for(Object V : listC) {
		        System.out.print(V + " 统计数组 ：");
		        }
		        }  
		     
	  
	     System.out.println("----------------------");
	     return total;
	}
	/**
	 *
	 * 新导出功能采购逐车明细
	 */
	public void getPurchPoundExports (String supplier,String receivingUnit,String materiel,String wagonNumber,String transport_unit,String driver,String matter_type,String start_time,String end_time,HttpServletResponse response) {
			String sql1 = "SELECT \r\n" + 
					//"	p.arrival_of_goods_number,p.supplier,p.materiel,p.wagon_number,p.transport_unit,p.old_net_weight,p.rough_weight,p.tare,p.net_weight,p.loss ,p.light_car_time,p.reconditioning_time \r\n" + 
					"p.arrival_of_goods_number,p.supplier,p.materiel,p.wagon_number,p.transport_unit,case when p.old_net_weight is null then 0 else p.old_net_weight end as old_net_weight,p.rough_weight,p.tare,p.net_weight,case when p.loss is null then 0 else p.loss end as loss ,p.light_car_time,p.reconditioning_time \r\n" + 
					"FROM \r\n" + 
					"	db_business_purchase_pound_list p \r\n"+ 
		            "WHERE   1 = 1 ";
			
			String sql5 = "SELECT \r\n" + 
					"		\"合计\" as arrival_of_goods_number ,\"\" as supplier ,\"\" as materiel,\"\" as wagon_number,\"\" as transport_unit,sum(p.old_net_weight) as old_net_weight,sum(p.rough_weight) as rough_weight,sum(p.tare) as tare,sum(p.net_weight) as net_weight,SUM(p.loss) as loss ,\"\" as light_car_time,\"\" as reconditioning_time \r\n" + 
					"	 FROM  \r\n" + 
					
					"	db_business_purchase_pound_list p \r\n"+ 
		            "WHERE   1 = 1 ";

         String sql2="";
			if(supplier != null && !supplier.isEmpty()){
				sql2 += " and p.supplier = '" + supplier + "'";
			}
			if(receivingUnit != null && !receivingUnit.isEmpty()){
				sql2 += " and p.receiving_unit =  '" + receivingUnit + "'";
			}
			if(materiel != null && !materiel.isEmpty()){
				sql2 += " and p.materiel = '" + materiel + "'";
			}
			if(wagonNumber != null && !wagonNumber.isEmpty()){
				sql2 += " and p.wagon_number =  '" + wagonNumber + "'";
			}
			if(transport_unit != null && !transport_unit.isEmpty()){
				sql2 += " and p.transport_unit = '" + transport_unit + "'";
			}
			if(driver != null && !driver.isEmpty()){
				sql2 += " and p.driver = '" + driver + "'";
			}
			if(matter_type != null && !matter_type.isEmpty()){
				sql2 += " and p.matter_type = '" + matter_type + "'";
			}
			if(start_time != null && !start_time.isEmpty()){
				sql2 += " and p.create_time >= '" + start_time + "'";
			}
			if(end_time != null && !end_time.isEmpty()) {
				 Long cTime= CommonsUtil.stringToTime(end_time)+86400000L;//时间加1天
				 String end=CommonsUtil.timeToString(cTime);
				sql2 += " and p.create_time < '" + end + "'";
			}
			System.out.println("（*************sql1列表**************）"+sql1);
			  String sql3= " order by p.create_time  desc  ";
			  String sqla=sql2.concat(sql3);
			  String sql=sql1.concat(sqla);//获取数据sql
			  String sqlb= sql5.concat(sqla);//合计
			  System.out.println("[(((((((((数据sql))))))))]"+sql);
			  System.out.println("[(((((((((合计sql))))))))]"+sqlb);
			List<Map<String, Object>> list= jdbc.queryForList(sql);//sql1
			Map<String, Object> count= jdbc.queryForMap(sqlb);
			list.add(count);

				//1.创建excel
				HSSFWorkbook wk = new HSSFWorkbook();
				CellStyle cs = wk.createCellStyle();
				CellStyle cs1 = wk.createCellStyle();
				cs.setBorderLeft(CellStyle.BORDER_THIN);
		        cs.setBorderRight(CellStyle.BORDER_THIN);
		        cs.setBorderTop(CellStyle.BORDER_THIN);
		        cs.setBorderBottom(CellStyle.BORDER_THIN);
		        cs.setAlignment(CellStyle.ALIGN_CENTER);
		        cs1.setAlignment(CellStyle.ALIGN_CENTER);
				//2.创建一张工作表
				HSSFSheet sheet = wk.createSheet();
				sheet.setColumnWidth(0, 256*20+150);
				sheet.setColumnWidth(1, 256*12+150);
				sheet.setColumnWidth(2, 256*12+150);
				sheet.setColumnWidth(3, 256*12+150);
				sheet.setColumnWidth(4, 256*18+150);
				sheet.setColumnWidth(5, 256*12+150);
				sheet.setColumnWidth(6, 256*12+150);
				sheet.setColumnWidth(7, 256*12+150);
				sheet.setColumnWidth(8, 256*12+150);
				sheet.setColumnWidth(9, 256*12+150);
				sheet.setColumnWidth(10,256*20+150);
				sheet.setColumnWidth(11,256*20+150);
				
				sheet.setDefaultRowHeightInPoints(50*50);
				
				HSSFPrintSetup printSetup = sheet.getPrintSetup();
				printSetup.setPaperSize(HSSFPrintSetup.A4_PAPERSIZE); // 纸张A5_PAPERSIZE  A4_PAPERSIZE
				sheet.setDisplayGridlines(false);
				sheet.setPrintGridlines(false);
				sheet.setMargin(HSSFSheet.TopMargin,( double ) 0.2 ); // 上边距
				sheet.setMargin(HSSFSheet.BottomMargin,( double ) 0.2 ); // 下边距
				sheet.setMargin(HSSFSheet.LeftMargin,( double ) 0.2 ); // 左边距
				sheet.setMargin(HSSFSheet.RightMargin,( double ) 0.2 ); // 右边距
				//3.设置工作表的列宽
				//sheet.setColumnWidth(0, 5000);
				//4.设置excel表头（创建第一行）行.列
				HSSFRow row0 = sheet.createRow(0);
				HSSFRow rowa = sheet.createRow(1);
				HSSFRow rowb = sheet.createRow(2);
				row0.setHeightInPoints(20);//目的是想把行高设置成20px
				//row0.getCell(0).setCellStyle(blackStyle);
				//row0.getCell(0).setCellStyle(blackStyle);
				HSSFRow row = sheet.createRow(3);
				HSSFCell cell0 = row0.createCell(0);
				HSSFCell cella = rowa.createCell(0);
				HSSFCell cellb = rowb.createCell(0);
				HSSFCell cell = row.createCell(0);
				
				// 设置字体
				CellStyle redStyle = wk.createCellStyle();
				//颜色HSSFColor 颜色索引对照表https://blog.csdn.net/for_china2012/article/details/29844661
				//居中
				redStyle.setAlignment(CellStyle.ALIGN_CENTER);
				cs1.setAlignment(CellStyle.ALIGN_LEFT);
				
				//cell.setCellStyle(redStyle);
				cell0.setCellStyle(redStyle);
				cella.setCellStyle(cs1);
				cellb.setCellStyle(cs1);
				HSSFFont font2 = wk.createFont();
				//字体
				//redFont.setFontName("宋体");
				//redStyle.setFontName("黑体");
				font2.setColor(Font.COLOR_RED);//红色
				font2.setFontName("仿宋_GB2312");
				font2.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);//粗体显示
				//设置字体大小
				font2.setFontHeightInPoints((short) 17);

				redStyle.setFont(font2);//选择需要用到的字体格式
				//cell0.setCellStyle(cs);
				
				//字段样式---》
				// 设置字体
				CellStyle css = wk.createCellStyle();

				CellStyle redStyle2 = wk.createCellStyle();
				//居中
				redStyle2.setAlignment(CellStyle.ALIGN_CENTER);
				redStyle2.setBorderLeft(CellStyle.BORDER_THIN);
				redStyle2.setBorderRight(CellStyle.BORDER_THIN);
				redStyle2.setBorderTop(CellStyle.BORDER_THIN);
				redStyle2.setBorderBottom(CellStyle.BORDER_THIN);
				HSSFFont font3 = wk.createFont();
				//字体
				font3.setColor(Font.BOLDWEIGHT_BOLD);//红色
				//font3.setFontName("仿宋_GB2312");黑体
				//font3.setFontName("黑体");
				font3.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);//粗体显示
				//设置字体大小
				font3.setFontHeightInPoints((short) 13);

				redStyle2.setFont(font3);//选择需要用到的字体格式
				//————————————————————————————
				String s_time="2019-03-28 09:27:57";
				String e_time="2019-06-28 09:27:57";
				String company="复兴煤业有限公司";
				cell0.setCellValue("山西复兴煤业有限公司采购逐车明细报表");
				cella.setCellValue("日期："+start_time+"至"+end_time);
				//(String supplier,String receivingUnit,String materiel,String wagonNumber,String transport_unit,String driver,String matter_type,String start_time,String end_time,
				cellb.setCellValue("条件："+supplier+"-"+materiel+"-"+wagonNumber);
			
				cell = row.createCell(0);
				//cell.setCellStyle(cs);
				cell.setCellStyle(redStyle2);
				cell.setCellValue("到货通知单号");
				
				cell = row.createCell(1);
				cell.setCellStyle(redStyle2);
				cell.setCellValue("供应商");
				
				cell = row.createCell(2);
				cell.setCellStyle(redStyle2);
				cell.setCellValue("物料");
				
				cell = row.createCell(3);
				cell.setCellStyle(redStyle2);
				cell.setCellValue("车号");
				
				cell = row.createCell(4);
				cell.setCellStyle(redStyle2);
				cell.setCellValue("运输单位");
				
				cell = row.createCell(5);
				cell.setCellStyle(redStyle2);
				cell.setCellValue("原发净重");
				
				cell = row.createCell(6);
				cell.setCellStyle(redStyle2);
				cell.setCellValue("毛重");
				
				cell = row.createCell(7);
				cell.setCellStyle(redStyle2);
				cell.setCellValue("皮重");
				
				cell = row.createCell(8);
				cell.setCellStyle(redStyle2);
				cell.setCellValue("净重");
				
				cell = row.createCell(9);
				cell.setCellStyle(redStyle2);
				cell.setCellValue("亏损");
				
				cell = row.createCell(10);
				cell.setCellStyle(redStyle2);
				cell.setCellValue("轻车时间");
				
				cell = row.createCell(11);
				cell.setCellStyle(redStyle2);
				cell.setCellValue("重车时间");
				
				
				//5.设置excel导出数据
				 // 创建第一行
		        for (short i=0;i<list.size();i++)
		        {
		            row = sheet.createRow(i+4);
		            Cell cell1 = row.createCell(0);
		            Cell cell2 = row.createCell(1);
		            Cell cell3 = row.createCell(2);
		            Cell cell4 = row.createCell(3);
		            Cell cell5 = row.createCell(4);
		            Cell cell6 = row.createCell(5);
		            Cell cell7 = row.createCell(6);
		            Cell cell8 = row.createCell(7);
		            Cell cell9 = row.createCell(8);
		            Cell cell10 = row.createCell(9);
		            Cell cell11 = row.createCell(10);
		            Cell cell12 = row.createCell(11);
		              cell1.setCellValue(String.valueOf( list.get(i).get("arrival_of_goods_number")));
		              cell1.setCellStyle(cs);
		              
		              cell2.setCellValue(String.valueOf(list.get(i).get("supplier")));
		              cell2.setCellStyle(cs);
		              
		              cell3.setCellValue(String.valueOf(list.get(i).get("materiel")));
		              cell3.setCellStyle(cs);
		              
		              cell4.setCellValue(String.valueOf(list.get(i).get("wagon_number")));
		              cell4.setCellStyle(cs);
		              
		              cell5.setCellValue(String.valueOf(list.get(i).get("transport_unit")));
		              cell5.setCellStyle(cs);
		              
		              cell6.setCellValue(String.valueOf(list.get(i).get("old_net_weight")));
		              cell6.setCellStyle(cs);
		              
		              cell7.setCellValue(String.valueOf(list.get(i).get("rough_weight")));
		              cell7.setCellStyle(cs);
		              
		              cell8.setCellValue(String.valueOf(list.get(i).get("tare")));
		              cell8.setCellStyle(cs);
		              
		              cell9.setCellValue(String.valueOf(list.get(i).get("net_weight")));
		              cell9.setCellStyle(cs);
		              
		              cell10.setCellValue(String.valueOf(list.get(i).get("loss")));
		              cell10.setCellStyle(cs);
		              
		              cell11.setCellValue(String.valueOf(list.get(i).get("light_car_time")));
		              cell11.setCellStyle(cs);
		              
		              cell12.setCellValue(String.valueOf(list.get(i).get("reconditioning_time")));
		              cell12.setCellStyle(cs);
		          }
		     
		          CellRangeAddress  range= new CellRangeAddress(0,0,0,11);
		          sheet.addMergedRegion(CellRangeAddress.valueOf("$A$2:$L$2"));
		          sheet.addMergedRegion(CellRangeAddress.valueOf("$A$3:$L$3"));  
		          sheet.addMergedRegion(range);
		  		//6.设置excel统计数据
		          try {
		        	  //response.setHeader("Content-type", "text/html;charset=UTF-8");
		      		//response.setContentType("application/vnd.ms-excel;charset=iso-8859-1");//application/json
		      		//response.setContentType("application/json;charset=UTF-8");
		      		// response.setContentType("application/vnd.ms-excel;charset=iso-8859-1");//
		      		//response.setCharacterEncoding("UTF-8");
		  			//response.setContentType("application/octet-stream");
		  			//response.setHeader("Content-disposition", "attachment;filename=采购逐车明细报表.xls");//默认Excel名称
		  			
		  			//response.setCharacterEncoding("UTF-8");
		  	      //  response.setContentType("application/vnd.ms-excel");vnd.ms-exce
		      		/*String fileName="采购逐车明细";
		  	        response.setHeader("content-disposition",
		  	                         "attachment;filename=" + new String(fileName.getBytes("utf-8"),"ISO-8859-1" )+ ".xls");
*/
		        	 
		  	        
		  	     /* response.setContentType("application/x-download");//下面三行是关键代码，处理乱码问题

                  response.setCharacterEncoding("utf-8"); */

                  //设置浏览器响应头对应的Content-disposition
		        	//  response.setContentType("application/octet-stream");
		        	  //response.setHeader("Content-disposition", "attachment;filename=" + fileName);
		        	 // response.setContentType("application/x-download");msexcel
		        	  String fileName="采购逐车明细";
		        	  response.setContentType("application/vnd.ms-excel");
		        	  //response.flushBuffer();
		        	  response.setCharacterEncoding("utf-8");
		        	 
                 // response.setHeader("Content-disposition", "attachment;filename="+new String(fileName.getBytes("gbk"), "iso8859-1")+".xls");
                  response.setHeader("content-disposition",
	                         "attachment;filename=" + new String(fileName.getBytes("utf-8"),"ISO-8859-1" )+ ".xls");
              //    String agent = ServletActionContext.getRequest().getHeader("User-Agent");
                  
                  
		  	        
		  	        
		  			response.flushBuffer();
		  			wk.write(response.getOutputStream());
		  			wk.write(new FileOutputStream(new File("D://daochu/采购逐车明细.xls")));
		  			
		  			
		  			
		  		} catch (FileNotFoundException e) {
		  			e.printStackTrace();
		  		} catch (IOException e) {
		  			e.printStackTrace();
		  		}
		  	}		            
	
	  
	public  Object[][] getPurchMatterCountExport(String supplier,String receivingUnit,String materiel,
			String wagonNumber,String transport_unit,String driver,String matter_type,String start_time,String end_time) {
		String prefix="select sum(t.vehicle_number) as c_vehicle_number  ,sum(t.t_old_net_weight) as c_old_net_weight,"
				+ "sum(t.t_rough_weight)as c_rough_weight,sum(t.t_tare) "
				+ "as c_tare,sum(t.t_net_weight) as c_net_weight,sum(t.t_loss) as c_loss from (";
			String sql1 = "SELECT \r\n" +  
					"	p.supplier,p.materiel,count(materiel) as vehicle_number,sum(old_net_weight) as t_old_net_weight,sum(rough_weight) "
					+ "as t_rough_weight,sum(tare)as t_tare,sum(net_weight) as t_net_weight ,sum(loss) as t_loss \r\n" + 
					"FROM \r\n" + 
					"	db_business_purchase_pound_list p \r\n" + 
					"WHERE   1 = 1 ";
			if(supplier != null && !supplier.isEmpty()){
				sql1 += " and p.supplier = '" + supplier + "'";
			}
			if(receivingUnit != null && !receivingUnit.isEmpty()){
				sql1 += " and p.receiving_unit =  '" + receivingUnit + "'";
			}
			if(materiel != null && !materiel.isEmpty()){
				sql1 += " and p.materiel = '" + materiel + "'";
			}
			if(wagonNumber != null && !wagonNumber.isEmpty()){
				sql1 += " and p.wagon_number =  '" + wagonNumber + "'";
			}
			if(transport_unit != null && !transport_unit.isEmpty()){
				sql1 += " and p.transport_unit = '" + transport_unit + "'";
			}
			if(driver != null && !driver.isEmpty()){
				sql1 += " and p.driver = '" + driver + "'";
			}
			if(matter_type != null && !matter_type.isEmpty()){
				sql1 += " and p.matter_type = '" + matter_type + "'";
			}
			
			if(start_time != null && !start_time.isEmpty()){
				sql1 += " and p.create_time >= '" + start_time + "'";
			}
			if(end_time != null && !end_time.isEmpty()) {
				 Long cTime= CommonsUtil.stringToTime(end_time)+86400000L;//时间加1天
				 String end=CommonsUtil.timeToString(cTime);
				sql1 += " and p.create_time < '" + end + "'";
			}
			sql1 +=" GROUP BY p.materiel \r\n";
			System.out.println("（*************sql1列表**************）"+sql1);
			sql1 += " order by p.create_time  desc  ";
			String Suffix=")t";
			String sqla=prefix.concat(sql1);
			String sql=sqla.concat(Suffix);
			List<Map<String, Object>> list = jdbc.queryForList(sql1);
			List<Map<String, Object>> list1 = jdbc.queryForList(sql);
			Map<String,Object> sa=list1.get(0);//获取合计数据
			
			String vehicle_number=String.valueOf(sa.get("c_vehicle_number"));
			String c_old_net_weight=String.valueOf(sa.get("c_old_net_weight"));
			String c_rough_weight=String.valueOf(sa.get("c_rough_weight"));
			String c_tare=String.valueOf(sa.get("c_tare"));
			String c_net_weight=String.valueOf(sa.get("c_net_weight"));
			String c_loss=String.valueOf(sa.get("c_loss"));
			
			String []one= {"合计"," ",vehicle_number,c_old_net_weight,c_rough_weight,c_tare,c_net_weight,c_loss};
			System.out.println("(-------输出one[]数组0------------)"+Arrays.toString(one));//输出数组
			int size = list.size();
	        Object[][] array = new Object[size][8];//数据二维数组
			String[] arr={"供应商","物料","车数","原发净重","毛重","皮重","净重","亏损"};
			 //表头 一维数组转进二维
		        int n = 8;//列
		        int m = arr.length/ n ;//行
		        Object [][] b = new Object[m][n];
		        int num = -1;
		        for (int i = 0; i < m; i++) {
		        for (int j = 0; j < n; j++) {
		        num++;
		        b[i][j] = arr[num];
		        }
		        }
		        System.out.println("-------输出arr[]数组1------------"+Arrays.toString(arr));
		        for (int i =0; i < size; i++) {//循环遍历所有行
		            array[i] = list.get(i).values().toArray();//每行的列数
		        }
		        //合并数组
		        Object[][] strs3 = Array.unite(b, array);
		        
		        //合计数据一维转二维
		        int x = 8;//列
		        int y = one.length/ x;//行
		        Object [][] c = new Object[y][x];
		        num = -1;
		        for (int i = 0; i < y; i++) {
		        for (int j = 0; j < x; j++) {
		        num++;
		        c[i][j] = one[num];
		        }
		        }
		        //合并统计数组
		        Object[][] total = Array.unite(strs3, c);
		        
			return total;
	}//
	//新物料统计报表导出
	public  void getPurchMatterCountExports(String supplier,String receivingUnit,String materiel,
			String wagonNumber,String transport_unit,String driver,String matter_type,String start_time,String end_time,HttpServletResponse response) {
		String prefix="select sum(t.vehicle_number) as c_vehicle_number  ,sum(t.t_old_net_weight) as c_old_net_weight,"
				+ "sum(t.t_rough_weight)as c_rough_weight,sum(t.t_tare) "
				+ "as c_tare,sum(t.t_net_weight) as c_net_weight,sum(t.t_loss) as c_loss from (";
			String sql1 = "SELECT \r\n" +  
					"	p.supplier,p.materiel,count(materiel) as vehicle_number,sum(old_net_weight) as t_old_net_weight,sum(rough_weight) "
					+ "as t_rough_weight,sum(tare)as t_tare,sum(net_weight) as t_net_weight ,sum(loss) as t_loss \r\n" + 
					"FROM \r\n" + 
					"	db_business_purchase_pound_list p \r\n" + 
					"WHERE   1 = 1 ";
			if(supplier != null && !supplier.isEmpty()){
				sql1 += " and p.supplier = '" + supplier + "'";
			}
			if(receivingUnit != null && !receivingUnit.isEmpty()){
				sql1 += " and p.receiving_unit =  '" + receivingUnit + "'";
			}
			if(materiel != null && !materiel.isEmpty()){
				sql1 += " and p.materiel = '" + materiel + "'";
			}
			if(wagonNumber != null && !wagonNumber.isEmpty()){
				sql1 += " and p.wagon_number =  '" + wagonNumber + "'";
			}
			if(transport_unit != null && !transport_unit.isEmpty()){
				sql1 += " and p.transport_unit = '" + transport_unit + "'";
			}
			if(driver != null && !driver.isEmpty()){
				sql1 += " and p.driver = '" + driver + "'";
			}
			if(matter_type != null && !matter_type.isEmpty()){
				sql1 += " and p.matter_type = '" + matter_type + "'";
			}
			
			if(start_time != null && !start_time.isEmpty()){
				sql1 += " and p.create_time >= '" + start_time + "'";
			}
			if(end_time != null && !end_time.isEmpty()) {
				 Long cTime= CommonsUtil.stringToTime(end_time)+86400000L;//时间加1天
				 String end=CommonsUtil.timeToString(cTime);
				sql1 += " and p.create_time < '" + end + "'";
			}
			sql1 +=" GROUP BY p.materiel \r\n";
			System.out.println("（*************sql1列表**************）"+sql1);
			sql1 += " order by p.create_time  desc  ";
			String Suffix=")t";
			String sqla=prefix.concat(sql1);
			String sql=sqla.concat(Suffix);
			List<Map<String, Object>> list = jdbc.queryForList(sql1);
			Map<String, Object> count = jdbc.queryForMap(sql);//获取合计数据
			Map<String,Object> counts=new HashMap();
			String vehicle_number=String.valueOf(count.get("c_vehicle_number"));
			String t_old_net_weight=String.valueOf(count.get("c_old_net_weight"));
			String t_rough_weight=String.valueOf(count.get("c_rough_weight"));
			String t_tare=String.valueOf(count.get("c_tare"));
			String t_net_weight=String.valueOf(count.get("c_net_weight"));
			String t_loss=String.valueOf(count.get("c_loss"));
			counts.put("supplier","合计");
			counts.put("materiel"," ");
			counts.put("vehicle_number",vehicle_number);
			counts.put("t_old_net_weight",t_old_net_weight);
			counts.put("t_rough_weight",t_rough_weight);
			counts.put("t_tare",t_tare);
			counts.put("t_net_weight",t_net_weight);
			counts.put("t_loss",t_loss);
			list.add(counts);
			//String []one= {"合计"," ",vehicle_number,c_old_net_weight,c_rough_weight,c_tare,c_net_weight,c_loss};
			
			
		//1.创建excel
		HSSFWorkbook wk = new HSSFWorkbook();
		CellStyle cs = wk.createCellStyle();
		cs.setBorderLeft(CellStyle.BORDER_THIN);
		cs.setBorderRight(CellStyle.BORDER_THIN);
		cs.setBorderTop(CellStyle.BORDER_THIN);
		cs.setBorderBottom(CellStyle.BORDER_THIN);
		cs.setAlignment(CellStyle.ALIGN_CENTER);
		//2.创建一张工作表
		HSSFSheet sheet = wk.createSheet();
		sheet.setColumnWidth(0, 256*20+150);
		sheet.setColumnWidth(1, 256*12+150);
		sheet.setColumnWidth(2, 256*12+150);
		sheet.setColumnWidth(3, 256*12+150);
		sheet.setColumnWidth(4, 256*18+150);
		sheet.setColumnWidth(5, 256*12+150);
		sheet.setColumnWidth(6, 256*12+150);
		sheet.setColumnWidth(7, 256*12+150);
		sheet.setColumnWidth(8, 256*12+150);
		sheet.setColumnWidth(9, 256*12+150);
		sheet.setColumnWidth(10,256*20+150);
		
		sheet.setDefaultRowHeightInPoints(50*50);
		
		HSSFPrintSetup printSetup = sheet.getPrintSetup();
		printSetup.setPaperSize(HSSFPrintSetup.A4_PAPERSIZE); // 纸张A5_PAPERSIZE  A4_PAPERSIZE
		sheet.setDisplayGridlines(false);
		sheet.setPrintGridlines(false);
		sheet.setMargin(HSSFSheet.TopMargin,( double ) 0.2 ); // 上边距
		sheet.setMargin(HSSFSheet.BottomMargin,( double ) 0.2 ); // 下边距
		sheet.setMargin(HSSFSheet.LeftMargin,( double ) 0.2 ); // 左边距
		sheet.setMargin(HSSFSheet.RightMargin,( double ) 0.2 ); // 右边距
		//3.设置工作表的列宽
		//sheet.setColumnWidth(0, 5000);
		//4.设置excel表头（创建第一行）
		HSSFRow row0 = sheet.createRow(0);
		row0.setHeightInPoints(25);//目的是想把行高设置成20px
		//	row0.getCell(0).setCellStyle(blackStyle);
		//row0.getCell(0).setCellStyle(blackStyle);
		HSSFRow rowa = sheet.createRow(1);
		HSSFRow rowb = sheet.createRow(2);
		HSSFRow row = sheet.createRow(3);
		HSSFCell cell0 = row0.createCell(0);
		
		HSSFCell cell = row.createCell(0);
		HSSFCell cella = rowa.createCell(0);
		HSSFCell cellb = rowb.createCell(0);
		
		// 设置字体
		CellStyle redStyle = wk.createCellStyle();
		redStyle.setWrapText(true);//自动换行
		//居中
		redStyle.setAlignment(CellStyle.ALIGN_CENTER);
		
		cell0.setCellStyle(redStyle);
		
		HSSFFont font2 = wk.createFont();
		//字体
		font2.setColor(Font.COLOR_RED);//红色
		font2.setFontName("仿宋_GB2312");
		font2.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);//粗体显示
		//设置字体大小
		font2.setFontHeightInPoints((short) 17);
		
		redStyle.setFont(font2);//选择需要用到的字体格式
		//cell0.setCellStyle(cs);
		
		//字段样式---》
		// 设置字体
		CellStyle css = wk.createCellStyle();
		
		CellStyle redStyle2 = wk.createCellStyle();
		//居中
		redStyle2.setAlignment(CellStyle.ALIGN_CENTER);
		redStyle2.setBorderLeft(CellStyle.BORDER_THIN);
		redStyle2.setBorderRight(CellStyle.BORDER_THIN);
		redStyle2.setBorderTop(CellStyle.BORDER_THIN);
		redStyle2.setBorderBottom(CellStyle.BORDER_THIN);
		HSSFFont font3 = wk.createFont();
		//字体
		font3.setColor(Font.BOLDWEIGHT_BOLD);//红色
		//font3.setFontName("仿宋_GB2312");黑体
		//font3.setFontName("黑体");
		font3.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);//粗体显示
		//设置字体大小
		font3.setFontHeightInPoints((short) 13);
		
		redStyle2.setFont(font3);//选择需要用到的字体格式
		//————————————————————————————
		
		cell0.setCellValue("山西复兴煤业有限公司采购物料统计报表");
		cella.setCellValue("日期："+start_time+"至"+end_time);
		cellb.setCellValue("条件:"+ supplier +"-"+ materiel+"-"+ wagonNumber+"-"+transport_unit+"-"+driver);
		
		cell = row.createCell(0);
		cell.setCellStyle(redStyle2);
		cell.setCellValue("供应商");
		
		cell = row.createCell(1);
		cell.setCellStyle(redStyle2);
		cell.setCellValue("物料");
		
		cell = row.createCell(2);
		cell.setCellStyle(redStyle2);
		cell.setCellValue("车数");
	
		cell = row.createCell(3);
		cell.setCellStyle(redStyle2);
		cell.setCellValue("原发净重");
		
		cell = row.createCell(4);
		cell.setCellStyle(redStyle2);
		cell.setCellValue("毛重");
		
		cell = row.createCell(5);
		cell.setCellStyle(redStyle2);
		cell.setCellValue("皮重");
		
		
		cell = row.createCell(6);
		cell.setCellStyle(redStyle2);
		cell.setCellValue("净重");
		
		cell = row.createCell(7);
		cell.setCellStyle(redStyle2);
		cell.setCellValue("亏损");
		
		
		
		//5.设置excel导出数据
		 // 创建第一行
		for (short i=0;i<list.size();i++)
		{
		    row = sheet.createRow(i+4);
		    Cell cell1 = row.createCell(0);
		    Cell cell2 = row.createCell(1);
		    Cell cell3 = row.createCell(2);
		    Cell cell4 = row.createCell(3);
		    Cell cell5 = row.createCell(4);
		    Cell cell6 = row.createCell(5);
		    Cell cell7 = row.createCell(6);
		    Cell cell8 = row.createCell(7);
		   
		  
		      cell1.setCellValue(String.valueOf(list.get(i).get("supplier")));
		      cell1.setCellStyle(cs);
		      
		      cell2.setCellValue(String.valueOf(list.get(i).get("materiel")));
		      cell2.setCellStyle(cs);
		      
		      cell3.setCellValue(String.valueOf(list.get(i).get("vehicle_number")));
		      cell3.setCellStyle(cs);
		      
		      cell4.setCellValue(String.valueOf(list.get(i).get("t_old_net_weight")));
		      cell4.setCellStyle(cs);
		      
		      cell5.setCellValue(String.valueOf(list.get(i).get("t_rough_weight")));
		      cell5.setCellStyle(cs);
		      
		      cell6.setCellValue(String.valueOf(list.get(i).get("t_tare")));
		      cell6.setCellStyle(cs);
		      
		      cell7.setCellValue(String.valueOf(list.get(i).get("t_net_weight")));
		      cell7.setCellStyle(cs);
		      
		      cell8.setCellValue(String.valueOf(list.get(i).get("t_loss")));
		      cell8.setCellStyle(cs);
		      
		      
		      
		  }
		  
		  CellRangeAddress  range= new CellRangeAddress(0,0,0,7);
		  sheet.addMergedRegion(CellRangeAddress.valueOf("$A$2:$H$2"));
          sheet.addMergedRegion(CellRangeAddress.valueOf("$A$3:$H$3")); 
		  sheet.addMergedRegion(range);
			//6.设置excel统计数据
		  try {
				//response.setContentType("application/octet-stream");
				//response.setHeader("Content-disposition", "attachment;filename=采购物料统计报表.xls");//默认Excel名称
			  String fileName="采购物料统计报表";
        	  response.setContentType("application/vnd.ms-excel");
        	  //response.flushBuffer();
        	  response.setCharacterEncoding("utf-8");
        	 
         // response.setHeader("Content-disposition", "attachment;filename="+new String(fileName.getBytes("gbk"), "iso8859-1")+".xls");
          response.setHeader("content-disposition",
                     "attachment;filename=" + new String(fileName.getBytes("utf-8"),"ISO-8859-1" )+ ".xls");
				response.flushBuffer();
				wk.write(response.getOutputStream());
				wk.write(new FileOutputStream(new File("D://daochu/采购物料统计.xls")));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			} catch (IOException e) {
				e.printStackTrace();
			}
		      
		        
	}//
	public Object[][] getPurchUnitCountExport(String supplier,String receivingUnit,String materiel,
			String wagonNumber,String transport_unit,String driver,String matter_type,String start_time,String end_time) {
		String prefix="select t.vehicle_number as c_vehicle_number ,sum(t_old_net_weight) as c_old_net_weight,"
				+ "sum(t_rough_weight)as c_rough_weight,sum(t_tare) "
				+ "as c_tare,sum(t_net_weight) as c_net_weight,sum(t_loss) as c_loss from (";
		String sql1 = "SELECT \r\n" + 
					"	p.supplier,p.materiel,count(supplier) as vehicle_number,sum(old_net_weight) as t_old_net_weight,sum(rough_weight) "
					+ "as t_rough_weight,sum(tare)as t_tare,sum(net_weight) as t_net_weight ,sum(loss) as t_loss \r\n" + 
					"FROM \r\n" + 
					"	db_business_purchase_pound_list p \r\n" + 
					"WHERE   1 = 1 ";
			if(supplier != null && !supplier.isEmpty()){
				sql1 += " and p.supplier = '" + supplier + "'";
			}
			if(receivingUnit != null && !receivingUnit.isEmpty()){
				sql1 += " and p.receiving_unit =  '" + receivingUnit + "'";
			}
			if(materiel != null && !materiel.isEmpty()){
				sql1 += " and p.materiel = '" + materiel + "'";
			}
			if(wagonNumber != null && !wagonNumber.isEmpty()){
				sql1 += " and p.wagon_number =  '" + wagonNumber + "'";
			}
			if(transport_unit != null && !transport_unit.isEmpty()){
				sql1 += " and p.transport_unit = '" + transport_unit + "'";
			}
			if(driver != null && !driver.isEmpty()){
				sql1 += " and p.driver = '" + driver + "'";
			}
			if(matter_type != null && !matter_type.isEmpty()){
				sql1 += " and p.matter_type = '" + matter_type + "'";
			}
			
			if(start_time != null && !start_time.isEmpty()){
				sql1 += " and p.create_time >= '" + start_time + "'";
			}
			if(end_time != null && !end_time.isEmpty()) {
				 Long cTime= CommonsUtil.stringToTime(end_time)+86400000L;//时间加1天
				 String end=CommonsUtil.timeToString(cTime);
				sql1 += " and p.create_time < '" + end + "'";
			}
			sql1 +=" GROUP BY p.supplier \r\n";
			System.out.println("（*************sql1列表**************）"+sql1);
			//sql1 += " and p.state <> 5 and p.state <> 6 " ;
			sql1 += " order by p.create_time  desc  ";
			String Suffix=")t";
			String sqla=prefix.concat(sql1);
			String sql=sqla.concat(Suffix);
			System.out.println(sql1+"<!!!!!!!!!!!!!!!!!!!!");
			List<Map<String, Object>> list = jdbc.queryForList(sql1);
			List<Map<String, Object>> list1 = jdbc.queryForList(sql);
			Map<String,Object> sa=list1.get(0);//获取合计数据
			String vehicle_number=String.valueOf(sa.get("c_vehicle_number"));
			String c_old_net_weight=String.valueOf(sa.get("c_old_net_weight"));
			String c_rough_weight=String.valueOf(sa.get("c_rough_weight"));
			String c_tare=String.valueOf(sa.get("c_tare"));
			String c_net_weight=String.valueOf(sa.get("c_net_weight"));
			String c_loss=String.valueOf(sa.get("c_loss"));
			
			String []one= {"合计"," ",vehicle_number,c_old_net_weight,c_rough_weight,c_tare,c_net_weight,c_loss};
			System.out.println("(-------输出one[]数组0------------)"+Arrays.toString(one));//输出数组
			int size = list.size();
	        Object[][] array = new Object[size][8];//数据二维数组
	        String[] arr={"供应商","物料","车数","原发净重","毛重","皮重","净重","亏损"};
	        for (int i =0; i < size; i++) {//循环遍历所有行
	            array[i] = list.get(i).values().toArray();//每行的列数
	        }
	        //表头 一维数组转进二维
	        int n = 8;//列
	        int m = arr.length/ n ;//行
	        Object [][] b = new Object[m][n];
	        int num = -1;
	        for (int i = 0; i < m; i++) {
	        for (int j = 0; j < n; j++) {
	        num++;
	        b[i][j] = arr[num];
	        }
	        }
	        //合并数组
	        Object[][] strs3 = Array.unite(b, array);
	        System.out.println("-------输出arr[]数组1------------"+Arrays.toString(arr));
	        //合计数据一维转二维
	        int x = 8;//列
	        int y = one.length/ x;//行
	        Object [][] c = new Object[y][x];
	        num = -1;
	        for (int i = 0; i < y; i++) {
	        for (int j = 0; j < x; j++) {
	        num++;
	        c[i][j] = one[num];
	        }
	        }
	        //合并统计数组
	        Object[][] total = Array.unite(strs3, c);
	        
	        
		return total;
	}
	public void  getPurchUnitCountExports(String supplier,String receivingUnit,String materiel,
			String wagonNumber,String transport_unit,String driver,String matter_type,String start_time,String end_time,HttpServletResponse response) {
		String prefix="select t.vehicle_number as c_vehicle_number ,sum(t_old_net_weight) as c_old_net_weight,"
				+ "sum(t_rough_weight)as c_rough_weight,sum(t_tare) "
				+ "as c_tare,sum(t_net_weight) as c_net_weight,sum(t_loss) as c_loss from (";
		String sql1 = "SELECT \r\n" + 
					"	p.supplier,p.materiel,count(supplier) as vehicle_number,sum(old_net_weight) as t_old_net_weight,sum(rough_weight) "
					+ "as t_rough_weight,sum(tare)as t_tare,sum(net_weight) as t_net_weight ,sum(loss) as t_loss \r\n" + 
					"FROM \r\n" + 
					"	db_business_purchase_pound_list p \r\n" + 
					"WHERE   1 = 1 ";
			if(supplier != null && !supplier.isEmpty()){
				sql1 += " and p.supplier = '" + supplier + "'";
			}
			if(receivingUnit != null && !receivingUnit.isEmpty()){
				sql1 += " and p.receiving_unit =  '" + receivingUnit + "'";
			}
			if(materiel != null && !materiel.isEmpty()){
				sql1 += " and p.materiel = '" + materiel + "'";
			}
			if(wagonNumber != null && !wagonNumber.isEmpty()){
				sql1 += " and p.wagon_number =  '" + wagonNumber + "'";
			}
			if(transport_unit != null && !transport_unit.isEmpty()){
				sql1 += " and p.transport_unit = '" + transport_unit + "'";
			}
			if(driver != null && !driver.isEmpty()){
				sql1 += " and p.driver = '" + driver + "'";
			}
			if(matter_type != null && !matter_type.isEmpty()){
				sql1 += " and p.matter_type = '" + matter_type + "'";
			}
			
			if(start_time != null && !start_time.isEmpty()){
				sql1 += " and p.create_time >= '" + start_time + "'";
			}
			if(end_time != null && !end_time.isEmpty()) {
				 Long cTime= CommonsUtil.stringToTime(end_time)+86400000L;//时间加1天
				 String end=CommonsUtil.timeToString(cTime);
				sql1 += " and p.create_time < '" + end + "'";
			}
			sql1 +=" GROUP BY p.supplier \r\n";
			System.out.println("（*************sql1列表**************）"+sql1);
			//sql1 += " and p.state <> 5 and p.state <> 6 " ;
			sql1 += " order by p.create_time  desc  ";
			String Suffix=")t";
			String sqla=prefix.concat(sql1);
			String sql=sqla.concat(Suffix);
			System.out.println(sql1+"<!!!!!!!!!!!!!!!!!!!!");
			List<Map<String, Object>> list = jdbc.queryForList(sql1);
			
			
			
			
			Map<String, Object> count = jdbc.queryForMap(sql);//获取合计数据
			Map<String,Object> counts=new HashMap();
			String vehicle_number=String.valueOf(count.get("c_vehicle_number"));
			String t_old_net_weight=String.valueOf(count.get("c_old_net_weight"));
			String t_rough_weight=String.valueOf(count.get("c_rough_weight"));
			String t_tare=String.valueOf(count.get("c_tare"));
			String t_net_weight=String.valueOf(count.get("c_net_weight"));
			String t_loss=String.valueOf(count.get("c_loss"));
			counts.put("supplier","合计");
			counts.put("materiel"," ");
			counts.put("vehicle_number",vehicle_number);
			counts.put("t_old_net_weight",t_old_net_weight);
			counts.put("t_rough_weight",t_rough_weight);
			counts.put("t_tare",t_tare);
			counts.put("t_net_weight",t_net_weight);
			counts.put("t_loss",t_loss);
			list.add(counts);
	      //1.创建excel
			HSSFWorkbook wk = new HSSFWorkbook();
			CellStyle cs = wk.createCellStyle();
			CellStyle cs1 = wk.createCellStyle();
			cs.setBorderLeft(CellStyle.BORDER_THIN);
	        cs.setBorderRight(CellStyle.BORDER_THIN);
	        cs.setBorderTop(CellStyle.BORDER_THIN);
	        cs.setBorderBottom(CellStyle.BORDER_THIN);
	        cs.setAlignment(CellStyle.ALIGN_CENTER);
	        cs1.setAlignment(CellStyle.ALIGN_CENTER);
			//2.创建一张工作表
			HSSFSheet sheet = wk.createSheet();
			sheet.setColumnWidth(0, 256*20+150);
			sheet.setColumnWidth(1, 256*12+150);
			sheet.setColumnWidth(2, 256*12+150);
			sheet.setColumnWidth(3, 256*12+150);
			sheet.setColumnWidth(4, 256*18+150);
			sheet.setColumnWidth(5, 256*12+150);
			sheet.setColumnWidth(6, 256*12+150);
			sheet.setColumnWidth(7, 256*12+150);
			
			sheet.setDefaultRowHeightInPoints(50*50);
			
			HSSFPrintSetup printSetup = sheet.getPrintSetup();
			printSetup.setPaperSize(HSSFPrintSetup.A4_PAPERSIZE); // 纸张A5_PAPERSIZE  A4_PAPERSIZE
			sheet.setDisplayGridlines(false);
			sheet.setPrintGridlines(false);
			sheet.setMargin(HSSFSheet.TopMargin,( double ) 0.2 ); // 上边距
			sheet.setMargin(HSSFSheet.BottomMargin,( double ) 0.2 ); // 下边距
			sheet.setMargin(HSSFSheet.LeftMargin,( double ) 0.2 ); // 左边距
			sheet.setMargin(HSSFSheet.RightMargin,( double ) 0.2 ); // 右边距
			//3.设置工作表的列宽
			//sheet.setColumnWidth(0, 5000);
			//4.设置excel表头（创建第一行）行.列
			HSSFRow row0 = sheet.createRow(0);
			HSSFRow rowa = sheet.createRow(1);
			HSSFRow rowb = sheet.createRow(2);
			row0.setHeightInPoints(20);//目的是想把行高设置成20px
			HSSFRow row = sheet.createRow(3);
			HSSFCell cell0 = row0.createCell(0);
			HSSFCell cella = rowa.createCell(0);
			HSSFCell cellb = rowb.createCell(0);
			HSSFCell cell = row.createCell(0);
			
			// 设置字体
			CellStyle redStyle = wk.createCellStyle();
			//颜色HSSFColor 颜色索引对照表https://blog.csdn.net/for_china2012/article/details/29844661
			//居中
			redStyle.setAlignment(CellStyle.ALIGN_CENTER);
			cs1.setAlignment(CellStyle.ALIGN_LEFT);
			
			cell0.setCellStyle(redStyle);
			cella.setCellStyle(cs1);
			cellb.setCellStyle(cs1);
			HSSFFont font2 = wk.createFont();
			//字体
			//redFont.setFontName("宋体");
			//redStyle.setFontName("黑体");
			font2.setColor(Font.COLOR_RED);//红色
			font2.setFontName("仿宋_GB2312");
			font2.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);//粗体显示
			//设置字体大小
			font2.setFontHeightInPoints((short) 17);

			redStyle.setFont(font2);//选择需要用到的字体格式
			//cell0.setCellStyle(cs);
			
			//字段样式---》
			// 设置字体
			CellStyle css = wk.createCellStyle();

			CellStyle redStyle2 = wk.createCellStyle();
			//居中
			redStyle2.setAlignment(CellStyle.ALIGN_CENTER);
			redStyle2.setBorderLeft(CellStyle.BORDER_THIN);
			redStyle2.setBorderRight(CellStyle.BORDER_THIN);
			redStyle2.setBorderTop(CellStyle.BORDER_THIN);
			redStyle2.setBorderBottom(CellStyle.BORDER_THIN);
			HSSFFont font3 = wk.createFont();
			//字体
			font3.setColor(Font.BOLDWEIGHT_BOLD);//红色
			//font3.setFontName("仿宋_GB2312");黑体
			//font3.setFontName("黑体");
			font3.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);//粗体显示
			//设置字体大小
			font3.setFontHeightInPoints((short) 13);

			redStyle2.setFont(font3);//选择需要用到的字体格式
			//————————————————————————————
			String s_time="2019-03-28 09:27:57";
			String e_time="2019-06-28 09:27:57";
			String company="复兴煤业有限公司";
			cell0.setCellValue("山西复兴煤业有限公司采购单位统计明细报表");
			cella.setCellValue("日期："+start_time+"至"+end_time);
			cellb.setCellValue("条件："+supplier+"-"+materiel+"-"+wagonNumber+"-"+driver+"-"+matter_type);
			cell = row.createCell(0);
			cell.setCellStyle(redStyle2);
			cell.setCellValue("供应商");
			
			cell = row.createCell(1);
			cell.setCellStyle(redStyle2);
			cell.setCellValue("物料");
			
			cell = row.createCell(2);
			cell.setCellStyle(redStyle2);
			cell.setCellValue("车数");
			
			cell = row.createCell(3);
			cell.setCellStyle(redStyle2);
			cell.setCellValue("原发净重");
			
			cell = row.createCell(4);
			cell.setCellStyle(redStyle2);
			cell.setCellValue("毛重");
			
			cell = row.createCell(5);
			cell.setCellStyle(redStyle2);
			cell.setCellValue("皮重");
			
			cell = row.createCell(6);
			cell.setCellStyle(redStyle2);
			cell.setCellValue("净重");
			
			cell = row.createCell(7);
			cell.setCellStyle(redStyle2);
			cell.setCellValue("亏损");
			
			
			//5.设置excel导出数据
			 // 创建第一行
	        for (short i=0;i<list.size();i++)
	        {
	            row = sheet.createRow(i+4);
	            Cell cell1 = row.createCell(0);
	            Cell cell2 = row.createCell(1);
	            Cell cell3 = row.createCell(2);
	            Cell cell4 = row.createCell(3);
	            Cell cell5 = row.createCell(4);
	            Cell cell6 = row.createCell(5);
	            Cell cell7 = row.createCell(6);
	            Cell cell8 = row.createCell(7);
	              cell1.setCellValue(String.valueOf( list.get(i).get("supplier")));
	              cell1.setCellStyle(cs);
	              
	              cell2.setCellValue(String.valueOf(list.get(i).get("materiel")));
	              cell2.setCellStyle(cs);
	              
	              cell3.setCellValue(String.valueOf(list.get(i).get("vehicle_number")));
	              cell3.setCellStyle(cs);
	              
	              cell4.setCellValue(String.valueOf(list.get(i).get("t_old_net_weight")));
	              cell4.setCellStyle(cs);
	              
	              cell5.setCellValue(String.valueOf(list.get(i).get("t_rough_weight")));
	              cell5.setCellStyle(cs);
	              
	              cell6.setCellValue(String.valueOf(list.get(i).get("t_tare")));
	              cell6.setCellStyle(cs);
	              
	              cell7.setCellValue(String.valueOf(list.get(i).get("t_net_weight")));
	              cell7.setCellStyle(cs);
	              
	              cell8.setCellValue(String.valueOf(list.get(i).get("t_loss")));
	              cell8.setCellStyle(cs);
	              
	          }
	     
	          CellRangeAddress  range= new CellRangeAddress(0,0,0,7);
	          sheet.addMergedRegion(CellRangeAddress.valueOf("$A$2:$H$2"));
	          sheet.addMergedRegion(CellRangeAddress.valueOf("$A$3:$H$3"));  
	          sheet.addMergedRegion(range);
	  		//6.设置excel统计数据
	          try {
	        	  String fileName="采购单位统计明细报表";
	        	  response.setContentType("application/vnd.ms-excel");
	        	  response.setCharacterEncoding("utf-8");
	          response.setHeader("content-disposition",
	                     "attachment;filename=" + new String(fileName.getBytes("utf-8"),"ISO-8859-1" )+ ".xls");
	        	  response.flushBuffer();
	  			wk.write(response.getOutputStream());
	  			wk.write(new FileOutputStream(new File("D://daochu/采购单位统计明细.xls")));
	  		} catch (FileNotFoundException e) {
	  			e.printStackTrace();
	  		} catch (IOException e) {
	  			e.printStackTrace();
	  		}
	        
	}
	
}
